#include <stdio.h>
#include <time.h>

// 计算斐波那契数列的第 n 项
long long fib(int n) {
    if (n <= 2) return 1;
    long long a = 1, b = 1;
    for (int i = 3; i <= n; i++) {
        long long temp = b;
        b += a;
        a = temp;
    }
    return b;
}

int main() {
    clock_t start, end;
    double cpu_time_used;
    int num = 0;
    long long result;

    // 记录开始时间
    start = clock();

    // 调用 fib 函数
    for (int i = 1; i <= 500; i++) {
        result = fib(i);
        num = i; // 只是为了保留与原代码相同的变量名
    }

    printf("num = %d\n", num);

    // 记录结束时间并输出结果
    end = clock();
    cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
    printf("C time: %f seconds\n", cpu_time_used);
    printf("Fibonacci number is: %lld\n", result);

    return 0;
}